package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.vo.CommunityChargeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.CommunityChargeMapper;
import com.ruoyi.system.domain.CommunityCharge;
import com.ruoyi.system.service.ICommunityChargeService;

/**
 * chargeService业务层处理
 *
 * @author wanglong
 * @date 2024-03-24
 */
@Service
public class CommunityChargeServiceImpl implements ICommunityChargeService
{
    @Autowired
    private CommunityChargeMapper communityChargeMapper;

    /**
     * 查询charge
     *
     * @param chargeId charge主键
     * @return charge
     */
    @Override
    public CommunityCharge selectCommunityChargeByChargeId(Long chargeId)
    {
        return communityChargeMapper.selectCommunityChargeByChargeId(chargeId);
    }

    /**
     * 查询charge列表
     *
     * @param communityCharge charge
     * @return charge
     */
    @Override
    public List<CommunityCharge> selectCommunityChargeList(CommunityCharge communityCharge)
    {
        return communityChargeMapper.selectCommunityChargeList(communityCharge);
    }

    /**
     * 统计12个月水电费和物业费
     *
     * @param communityCharge charge
     * @return charge集合
     */
    @Override
    public List<CommunityChargeVo> selectCommunityChargeSum(CommunityChargeVo communityCharge) {
        return communityChargeMapper.selectCommunityChargeSum(communityCharge);
    }


    /**
     * 新增charge
     *
     * @param communityCharge charge
     * @return 结果
     */
    @Override
    public int insertCommunityCharge(CommunityCharge communityCharge)
    {
        communityCharge.setChargeDate(communityCharge.getPayerDate());
        communityCharge.setCreateTime(DateUtils.getNowDate());
        communityCharge.setCreateBy(SecurityUtils.getUsername());
        return communityChargeMapper.insertCommunityCharge(communityCharge);
    }

    /**
     * 修改charge
     *
     * @param communityCharge charge
     * @return 结果
     */
    @Override
    public int updateCommunityCharge(CommunityCharge communityCharge)
    {
        communityCharge.setUpdateTime(DateUtils.getNowDate());
        return communityChargeMapper.updateCommunityCharge(communityCharge);
    }

    /**
     * 批量删除charge
     *
     * @param chargeIds 需要删除的charge主键
     * @return 结果
     */
    @Override
    public int deleteCommunityChargeByChargeIds(Long[] chargeIds)
    {
        return communityChargeMapper.deleteCommunityChargeByChargeIds(chargeIds);
    }

    /**
     * 删除charge信息
     *
     * @param chargeId charge主键
     * @return 结果
     */
    @Override
    public int deleteCommunityChargeByChargeId(Long chargeId)
    {
        return communityChargeMapper.deleteCommunityChargeByChargeId(chargeId);
    }


}
